<template>
  <div class="marquee">
    <div class="marquee_box" @click="toSearchBox">
      <van-icon name="search" class="el-icon-search" size="1.5rem" />
      <ul class="marquee_list" :class="{ marquee_top: animate }">
        <li v-for="(item, index) in marqueeList" :key="index">
          <span>{{ item.name }}</span>
          <span class="red"> {{ item.mark }}</span>
          <span class="red"> {{ item.namesong }}</span>
        </li>
      </ul>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      animate: false,
      marqueeList: [
        {
          name: "温奕心",
          mark: "-",
          namesong: "一路生花",
        },
        {
          name: "黄龄",
          mark: "-",
          namesong: "叹",
        },
        {
          name: "李尖尖",
          mark: "-",
          namesong: "氧化氢",
        },
        {
          name: "付雪",
          mark: "-",
          namesong: "金玉良缘",
        },
      ],
    };
  },
  created: function () {
    setInterval(this.showMarquee, 2000);
  },
  methods: {
    showMarquee: function () {
      this.animate = true;
      setTimeout(() => {
        this.marqueeList.push(this.marqueeList[0]);
        this.marqueeList.shift();
        this.animate = false;
      }, 500);
    },
    toSearchBox() {
      this.$router.push("/MusicSearchBox");
    },
  },
};
</script>
<style lang="less">
img {
  display: flex;
  box-sizing: border-box;
}
.marquee {
  width: 90%;
  height: 40px;
  margin: 8px auto;
  align-items: center;
  color: #333;
  opacity: 0.5;
  background-color: #edeff2 !important;
  display: flex;
  border-radius: 8885px;
  box-sizing: border-box;
}
.marquee_title {
  height: 30px;
  font-size: 14px;
  align-items: center;
}
.marquee_box {
  position: relative;
  width: 100%;
  height: 30px;
  overflow: hidden;
}
.el-icon-search {
  position: absolute;
  left: -40vw;
  font-weight: 400;

  top: 50%;
  transform: translateY(-50%);
}
.marquee_list {
  display: block;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%);
}
.marquee_top {
  transition: all 0.5s;
  margin-top: -30px;
}
.marquee_list li {
  height: 30px;
  line-height: 30px;
  font-size: 14px;
  padding-left: 20px;
}
.marquee_list li span {
  padding: 0 2px;
}
.red {
  color: #222222;
}
</style>